#include <bits/stdc++.h>
using namespace std;
const int maxn = 8+2;
int d[maxn][maxn];
int r0, c0, r2, c2;

typedef pair<int, int> pii;
string sta, over;
int dr[] = {-1, -2, 1, 2, 1, 2, -1, -2};
int dc[] = {2, 1, 2, 1, -2, -1, -2, -1};

inline bool in(int r, int c){
    return r>=1 && r<=8 && c>=1 && c<=8;
}

void print(){
    cout << "To get from " << sta << " to " << over << " takes " << d[r2][c2] << " knight moves.\n";
}
void bfs(){
    memset(d, -1, sizeof(d));
    queue<pii> q;
    q.push(make_pair(r0, c0));
    d[r0][c0] = 0;
    while(q.size()){
        int r = q.front().first, c = q.front().second; q.pop();
        if(r==r2 && c==c2){
            print();break;}
        for (int i = 0; i < 8; ++i) {
            int r1 = r+dr[i], c1 = c+dc[i];
            if(in(r1, c1) && d[r1][c1]<0){
                q.push(make_pair(r1, c1));
                d[r1][c1] = d[r][c] + 1;
            }
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    while(cin >> sta >> over){
        c0 = sta[0]-'a'+1, r0 = 9-(sta[1]-'0');
        c2 = over[0]-'a'+1, r2 = 9-(over[1]-'0');
        bfs();
    }
    return 0;
}